<template>
  <div class="page">
    <div class="c-main p20">
      <div class="c-body">
        <el-row type="flex" justify="center">
          <el-col :span="24">
            <el-form
              ref="form"
              :model="pageAjax.data"
              :rules="pageAjax.rules"
              label-width="120px"
            >
              <div class="block">
                <el-form-item label="来源：" class="inlineBlock">
                  <el-radio-group v-model="pageAjax.data.source" size="medium">
                    <el-radio border :label="0">自招</el-radio>
                    <el-radio border :label="1">星探</el-radio>
                    <el-radio border :label="2">联营</el-radio>
                  </el-radio-group>
                </el-form-item>
                <div class="block">
                  <el-form-item label="">
                    <el-radio-group
                      v-model="pageAjax.data.onlineType"
                      size="small"
                      v-if="pageAjax.data.source == 0"
                    >
                      <el-radio value="ONLINE" label="ONLINE">线上</el-radio>
                      <el-radio value="OFFLINE" label="OFFLINE">线下</el-radio>
                    </el-radio-group>
                    <el-input
                      placeholder="输入星探资料"
                      v-model="pageAjax.data.scoutName"
                      v-else-if="pageAjax.data.source == 1"
                    >
                    </el-input>
                    <el-input
                      placeholder="输入联营资料"
                      v-model="pageAjax.data.unionName"
                      v-else
                    >
                    </el-input>
                  </el-form-item>
                </div>
              </div>
              <div class="block">
                <el-form-item
                  label="昵称："
                  class="inlineBlock"
                  prop="nickName"
                >
                  <el-input placeholder="昵称" v-model="pageAjax.data.nickName">
                  </el-input>
                </el-form-item>
                <el-form-item
                  label="微信号："
                  class="inlineBlock"
                  v-if="isShowContact"
                >
                  <el-input
                    placeholder="微信号"
                    v-model="pageAjax.data.wxNo"
                  ></el-input>
                </el-form-item>
                <el-form-item label="性别：" class="inlineBlock">
                  <el-radio-group v-model="pageAjax.data.gender" size="medium">
                    <el-radio border :label="1">男</el-radio>
                    <el-radio border :label="2">女</el-radio>
                  </el-radio-group>
                </el-form-item>
                <el-form-item
                  label="联系电话："
                  class="inlineBlock"
                  v-if="isShowContact"
                >
                  <el-input
                    placeholder="联系电话"
                    v-model="pageAjax.data.contractPhone"
                  >
                  </el-input>
                </el-form-item>
                <el-form-item
                  label="身份证号码："
                  class="inlineBlock"
                  v-if="isShowContact"
                >
                  <el-input
                    placeholder="身份证号码"
                    v-model="pageAjax.data.idCard"
                  >
                  </el-input>
                </el-form-item>
              </div>
              <el-divider></el-divider>
              <div class="mi-upload">
                <div class="mi-title">
                  上传图片(最多5张，第一张默认为主播头像)
                </div>

                <div class="m-files">
                  <div class="m-preview clearfix">
                    <div
                      class="m-file"
                      v-for="(item, index) in pageAjax.data.pics"
                      :key="index"
                    >
                      <div class="m-operation flex item-v-center item-h-center">
                        <i
                          class="el-icon-delete danger-text"
                          @click="rDeleteUploadImg(index)"
                        ></i>
                        <i class="el-icon-view" @click="rViewImg(index)"></i>
                      </div>
                      <img :src="item" alt="" />
                    </div>
                    <div
                      class="m-file m-addBtn flex item-v-center item-h-center"
                    >
                      <el-upload
                        class="diy-uploadBtn fr"
                        :action="uploadImgAjax.config.url"
                        :headers="uploadImgAjax.config.headers"
                        :multiple="false"
                        name="file"
                        ref="uploadImg"
                        accept=".jpg, .gif, .jpeg, .png"
                        :show-file-list="false"
                        :disabled="uploadImgAjax.config.disabled"
                        :on-success="rUploadImgSuc"
                        :on-error="rUploadImgFail"
                        :on-progress="rUploadImgProgress"
                        :before-upload="rUploadImgBefore"
                        :limit="1"
                      >
                        <i class="el-icon-plus"></i>
                      </el-upload>
                    </div>
                  </div>
                </div>
              </div>
              <el-divider></el-divider>
              <div class="mi-upload">
                <div class="mi-title">
                  上传视频(最多3个)
                </div>
                <div class="m-files">
                  <div class="m-preview clearfix">
                    <div
                      class="m-file"
                      v-for="(item, index) in pageAjax.data.videos"
                      :key="index"
                    >
                      <div class="m-operation flex item-v-center item-h-center">
                        <i
                          class="el-icon-delete danger-text"
                          @click="rDeleteUploadVideo(index)"
                        ></i>
                        <i class="el-icon-view" @click="rViewVideo(item)"></i>
                      </div>
                      <video :src="item"></video>
                    </div>
                    <div
                      class="m-file m-addBtn flex item-v-center item-h-center"
                    >
                      <el-upload
                        class="diy-uploadBtn fr"
                        :action="uploadVideoAjax.config.url"
                        :headers="uploadVideoAjax.config.headers"
                        :multiple="false"
                        name="file"
                        ref="uploadVideo"
                        accept=".mp4, .avi, .flv"
                        :show-file-list="false"
                        :disabled="uploadVideoAjax.config.disabled"
                        :on-success="rUploadVideoSuc"
                        :on-error="rUploadVideoFail"
                        :on-progress="rUploadVideoProgress"
                        :before-upload="rUploadVideoBefore"
                        :limit="1"
                      >
                        <i class="el-icon-plus"></i>
                      </el-upload>
                    </div>
                  </div>
                </div>
              </div>
              <el-divider></el-divider>
              <div class="c-videoLink">
                <el-form-item label="增加视频链接">
                  <el-button
                    size="small"
                    type="primary"
                    icon="el-icon-circle-plus-outline"
                    @click="rAddVideoLink"
                    >增加视频链接</el-button
                  >
                </el-form-item>
                <div class="block">
                  <el-form-item
                    v-for="(item, index) in pageAjax.data.videoLinks"
                    :label="'视频链接' + (index + 1)"
                    :key="index"
                    class="block"
                  >
                    <el-input
                      v-model="pageAjax.data.videoLinks[index]"
                    ></el-input>
                    <el-button @click="rDeleteVideoLink(index)">删除</el-button>
                  </el-form-item>
                </div>
              </div>
              <el-divider></el-divider>
              <el-form-item
                label="是否有直播经验："
                class="inlineBlock"
                label-width="150px"
              >
                <el-radio-group
                  v-model="pageAjax.data.hasLiveExperience"
                  size="medium"
                >
                  <el-radio border :label="1">是</el-radio>
                  <el-radio border :label="0">否</el-radio>
                </el-radio-group>
              </el-form-item>
              <div
                class="c-liveExpEditVoList"
                v-if="pageAjax.data.hasLiveExperience"
              >
                <el-form-item label="增加直播经验">
                  <el-button
                    size="small"
                    type="primary"
                    icon="el-icon-circle-plus-outline"
                    @click="rAddLiveExpEditVo"
                    >增加直播经验</el-button
                  >
                </el-form-item>
                <div
                  class="block"
                  v-for="(item, index) in pageAjax.data.liveExpEditVoList"
                  :key="index"
                >
                  <div class="block c-liveExpEditVo">
                    <div class="mi-title">
                      <el-form-item :label="'直播经验' + (index + 1)">
                        <el-button
                          size="small"
                          type="danger"
                          icon="el-icon-delete"
                          @click="rDeleteLiveExpEditVo"
                          >删除直播经验</el-button
                        >
                      </el-form-item>
                    </div>
                    <el-form-item label="直播平台" class="label-must">
                      <!-- <el-select
                        v-model="
                          pageAjax.data.liveExpEditVoList[index].platfomId
                        "
                        placeholder="请选择"
                      >
                        <el-option
                          v-for="item in $store.state.wantPlatformList"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id"
                        >
                        </el-option>
                      </el-select> -->
                      <!-- <el-cascader
                        v-model="
                          pageAjax.data.liveExpEditVoList[index].platfomId
                        "
                        :props="{
                          value: 'id',
                          label: 'name',
                          emitPath: false,
                          checkStrictly: true
                        }"
                        :options="
                          $store.getters.allPlatformListOffspringnTreeData
                        "
                      >
                      </el-cascader> -->
                      <!-- <el-cascader
                        v-model="
                          pageAjax.data.liveExpEditVoList[index].platfomId
                        "
                        :props="{
                          value: 'id',
                          label: 'name',
                          emitPath: false,
                          multiple: false,
                          checkStrictly: true
                        }"
                        :options="platformListSupAjax.oldPlatfomList"
                      >
                      </el-cascader> -->
                      <el-input
                        placeholder="直播平台"
                        v-model="
                          pageAjax.data.liveExpEditVoList[index].platfomId
                        "
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="直播id" class="label-must">
                      <el-input
                        placeholder="直播id"
                        v-model="pageAjax.data.liveExpEditVoList[index].liveId"
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="粉丝数量">
                      <el-input
                        placeholder="粉丝数量"
                        v-model="
                          pageAjax.data.liveExpEditVoList[index].fansCount
                        "
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="原公会">
                      <el-input
                        placeholder="原公会"
                        v-model="
                          pageAjax.data.liveExpEditVoList[index].tradeUnion
                        "
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="月流水">
                      <el-input
                        placeholder="月流水"
                        v-model="
                          pageAjax.data.liveExpEditVoList[index].monthStream
                        "
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="原待遇">
                      <el-input
                        placeholder="原待遇"
                        v-model="
                          pageAjax.data.liveExpEditVoList[index].monthIncome
                        "
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="直播等级">
                      <el-input
                        placeholder="直播等级"
                        v-model="pageAjax.data.liveExpEditVoList[index].level"
                      ></el-input>
                    </el-form-item>
                    <el-row>
                      <el-col :span="20">
                        <el-form-item label="直播年限">
                          <el-input
                            placeholder="直播年限"
                            v-model="
                              pageAjax.data.liveExpEditVoList[index]
                                .broadcastYears
                            "
                          ></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :span="4">
                        <el-button
                          type="text"
                          style="margin-left: 5px;"
                          disabled=""
                          >年</el-button
                        >
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :span="20">
                        <el-form-item label="日均直播时长">
                          <el-input
                            placeholder="日均直播时长"
                            v-model="
                              pageAjax.data.liveExpEditVoList[index]
                                .totalLiveTime
                            "
                          ></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :span="4">
                        <el-button
                          type="text"
                          style="margin-left: 5px;"
                          disabled=""
                          >小时/日</el-button
                        >
                      </el-col>
                    </el-row>

                    <div class="">
                      <div class="mi-title">
                        直播时间段
                      </div>
                      <div class="">
                        <el-form-item label="开始时间">
                          <el-time-picker
                            v-model="
                              pageAjax.data.liveExpEditVoList[index]
                                .liveTimeStart
                            "
                            placeholder="开始时间"
                            format="HH:mm"
                            value-format="HH:mm"
                          >
                          </el-time-picker>
                        </el-form-item>
                        <el-form-item label="结束时间">
                          <el-time-picker
                            v-model="
                              pageAjax.data.liveExpEditVoList[index].liveTimeEnd
                            "
                            placeholder="结束时间"
                            format="HH:mm"
                            value-format="HH:mm"
                          >
                          </el-time-picker>
                        </el-form-item>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
              <el-divider></el-divider>
              <div class="block">
                <div class="block">
                  <el-form-item class="block" label-width="0">
                    <el-row type="flex" justify="center">
                      <el-col :sm="4" :md="4" :lg="3">
                        <span class="pl20">才艺选择：</span>
                      </el-col>
                      <el-col :sm="20" :md="20" :lg="21">
                        <el-checkbox-group v-model="pageAjax.data.talentSkills">
                          <el-checkbox
                            v-for="item in $store.state.skillList"
                            :label="item.id"
                            name="type"
                            :key="item.id"
                            :value="item.id"
                            >{{ item.value }}</el-checkbox
                          >
                        </el-checkbox-group>
                      </el-col>
                    </el-row>
                  </el-form-item>
                </div>
                <div class="block">
                  <el-form-item label="其他">
                    <el-input
                      placeholder="其他"
                      v-model="pageAjax.data.talentSkillExt"
                    ></el-input>
                  </el-form-item>
                </div>

                <div class="block">
                  <el-form-item label="主播发展意向">
                    <el-input
                      type="textarea"
                      v-model="pageAjax.data.artistDevIntention"
                    ></el-input>
                  </el-form-item>
                </div>

                <div class="block">
                  <div class="block">
                    <el-form-item class="block" label-width="0">
                      <el-row type="flex" justify="center">
                        <el-col :sm="4" :md="4" :lg="3">
                          <span class="pl20"
                            ><span class="text-warning">*</span>意向平台：</span
                          >
                        </el-col>
                        <el-col :sm="20" :md="20" :lg="21">
                          <!-- <el-cascader
                            v-model="pageAjax.data.intentionPlatforms"
                            :props="{
                              multiple: true,
                              label: 'name',
                              value: 'id',
                              emitPath: false
                            }"
                            :options="platformListSupAjax.data
                            "
                          >
                          </el-cascader> -->
                          <el-cascader
                            v-model="pageAjax.data.intentionPlatforms"
                            :props="{
                              multiple: true,
                              label: 'name',
                              value: 'id',
                              emitPath: false
                            }"
                            clearable
                            :options="platformListSupAjax.wantPlatformList"
                            :key="Math.random()"
                          >
                          </el-cascader>
                          <!-- <el-checkbox-group
                            v-model="pageAjax.data.intentionPlatforms"
                          >
                            <el-checkbox
                              v-for="item in $store.state.wantPlatformList"
                              :label="item.id"
                              name="type"
                              :key="item.id"
                              :value="item.id"
                              >{{ item.name }}</el-checkbox
                            >
                          </el-checkbox-group> -->
                        </el-col>
                      </el-row>
                    </el-form-item>
                  </div>
                  <div class="block">
                    <el-form-item label="其他">
                      <el-input
                        placeholder="其他"
                        v-model="pageAjax.data.intentionPlatformExt"
                      ></el-input>
                    </el-form-item>
                  </div>
                </div>
                <div class="block">
                  <el-divider></el-divider>
                  <div class="mi-title">
                    期望待遇
                  </div>
                  <el-form-item label="底薪">
                    <el-input
                      placeholder="底薪"
                      v-model="pageAjax.data.expectedBaseSalary"
                    ></el-input>
                  </el-form-item>
                  <el-form-item label="保底">
                    <el-input
                      placeholder="保底"
                      v-model="pageAjax.data.expectedBottomGuard"
                    ></el-input>
                  </el-form-item>
                  <el-form-item label="签约金">
                    <el-input
                      placeholder="签约金"
                      v-model="pageAjax.data.expectedSigningBonus"
                    ></el-input>
                  </el-form-item>
                  <el-form-item label="其他">
                    <el-input
                      placeholder="其他"
                      v-model="pageAjax.data.expectedOther"
                    ></el-input>
                  </el-form-item>
                </div>
              </div>
              <div class="block">
                <el-divider></el-divider>
                <div class="mi-title">
                  招募评价
                </div>
                <div class="block">
                  <el-form-item label="外貌评价" class="label-must">
                    <el-rate v-model="alone.pageAjax.data.starLooks"></el-rate>
                  </el-form-item>
                </div>
                <div class="block">
                  <el-form-item label="才艺评价" class="label-must">
                    <el-rate v-model="alone.pageAjax.data.starSkills"></el-rate>
                  </el-form-item>
                </div>
                <div class="block">
                  <el-form-item label="口才评价" class="label-must">
                    <el-rate
                      v-model="alone.pageAjax.data.starEloquence"
                    ></el-rate>
                  </el-form-item>
                </div>
                <div class="block">
                  <el-form-item label="其他意见">
                    <el-input
                      type="textarea"
                      v-model="alone.pageAjax.data.otherOpinion"
                    ></el-input>
                  </el-form-item>
                </div>
              </div>
              <div class="block">
                <el-form-item class="block" label-width="0">
                  <el-row type="flex" justify="center">
                    <el-col :sm="6" :md="6" :lg="4">
                      <span class="pl20"
                        ><span class="text-warning">*</span
                        >发布公司及对应平台：</span
                      >
                    </el-col>
                    <el-col :sm="18" :md="18" :lg="20">
                      <!-- <el-cascader
                        v-model="pageAjax.data.publishPlatformIds"
                        :props="{
                          multiple: true,
                          label: 'name',
                          value: 'id',
                          emitPath: false
                        }"
                        :options="$store.getters.platformListOffspringnTreeData"
                      >
                      </el-cascader> -->
                      <!-- <el-checkbox-group
                        v-model="pageAjax.data.publishPlatformIds"
                      >
                        <el-checkbox
                          v-for="item in $store.state.platformList"
                          :label="item.id"
                          name="type"
                          :key="item.id"
                          :value="item.id"
                          >{{ item.name }}</el-checkbox
                        >
                      </el-checkbox-group> -->
                      <el-cascader
                        v-model="pageAjax.data.publishCorpIds"
                        v-if="$store.getters.hasChildrenCorporations"
                        :props="{
                          multiple: true,
                          label: 'name',
                          value: 'id',
                          emitPath: false,
                          checkStrictly: true
                        }"
                        :options="$store.state.userData.corporations"
                        placeholder="请选择发布的公司"
                        @change="rChangePublishCorporations"
                      >
                      </el-cascader>
                      <el-cascader
                        v-model="pageAjax.data.publishPlatformIds"
                        :props="{
                          multiple: true,
                          label: 'name',
                          value: 'id',
                          emitPath: false
                        }"
                        :options="alone.platformList"
                        clearable
                        :key="Math.random()"
                        placeholder="请选择发布的平台"
                      >
                      </el-cascader>
                    </el-col>
                  </el-row>
                </el-form-item>
              </div>
              <el-form-item class="block tc">
                <el-button type="primary" @click="rSubmitForm">提交</el-button>
                <el-button @click="back">取消</el-button>
              </el-form-item>
            </el-form>
          </el-col>
        </el-row>
      </div>
    </div>
    <!-- 图片预览插件 -->
    <!-- <el-image-viewer
      v-if="imgPreviewCp.config.show"
      :on-close="rCloseImgPreviewCp"
      :url-list="imgPreviewCp.data"
    /> -->
    <yj-img-preview
      :pics="imgPreviewCp.data"
      :initIndex="imgPreviewCp.index"
      :show="imgPreviewCp.config.show"
      @close="rCloseImgPreviewCp"
    >
    </yj-img-preview>
    <!-- 视频预览 -->
    <el-dialog
      title
      :visible.sync="videoPreviewCp.config.show"
      width="60%"
      class="videoPreviewCpClass"
      @close="rCloseVideoPreviewCp"
    >
      <div class="c-videoBox">
        <div class="c-video">
          <video
            :src="videoPreviewCp.data.src"
            controls
            autoplay
            class="video"
            ref="videoPreviewCpRef"
            width="100%"
          ></video>
        </div>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { updateActor, getActorInfo } from "@/api/actor.js";
import { getOffspringnTree, tileNestingData } from "@/assets/js/util.js";
import { getAllCorporationsPlatformList } from "@/api/others.js";
import { getPlatformList } from "@/api/authority.js";
import _ from "lodash";

export default {
  name: "editActor",
  data: () => ({
    pageAjax: {
      loading: false,
      data: {
        gender: 1,
        liveExpEditVoList: [],
        publishCorpIds: [],
        publishPlatformIds: [],
        intentionPlatforms: [],
        talentSkills: [],
        sourceDetail: "",
        source: 0,
        videoLinks: [],
        pics: [],
        videos: [],
        onlineType: "ONLINE"
      },
      rules: {
        nickName: [{ required: true, message: "请输入昵称", trigger: "blur" }]
      }
    },
    platformListSupAjax: {
      oldPlatfomList: [], // 用于直播经验里面的直播id
      wantPlatformList: [] // 意向主播
    },
    // platformListSupAjax: {
    //   data: []
    // },
    uploadImgAjax: {
      loading: false,
      config: {
        disabled: false,
        headers: {
          Authorization: ""
        },
        url: "/bs/upload"
      }
    },
    uploadVideoAjax: {
      loading: false,
      config: {
        disabled: false,
        headers: {
          Authorization: ""
        },
        url: "/bs/upload"
      }
    },

    alone: {
      pageAjax: {
        data: {}
      },
      platformList: []
    },
    imgPreviewCp: {
      config: {
        show: false
      },
      data: []
    },
    videoPreviewCp: {
      config: {
        show: false
      },
      data: {
        src: ""
      }
    }
  }),
  watch: {
    "pageAjax.data"() {
      let anchorRecruitAppraise =
        this.pageAjax.data.anchorRecruitAppraise || {};
      this.alone.pageAjax.data = {
        otherOpinion: anchorRecruitAppraise.otherOpinion,
        starLooks: anchorRecruitAppraise.starLooks,
        starSkills: anchorRecruitAppraise.starSkills,
        starEloquence: anchorRecruitAppraise.starEloquence
      };
    }
  },
  computed: {
    isShowContact: function() {
      let _that = this;
      let anchorRecruitAppraise =
        _that.pageAjax.data.anchorRecruitAppraise || {};
      let recruit = anchorRecruitAppraise.recruit || {};
      let signStatusCanShow =
        _that.pageAjax.data.signStatus == "SIGNING" ||
        _that.pageAjax.data.signStatus == "SIGNED";
      let isSeestarOwn =
        recruit.userId && recruit.userId == this.$store.state.userData.userId;
      if (signStatusCanShow || isSeestarOwn) {
        return true;
      }
      return false;
    }
  },
  created() {
    let _that = this;
    // _that.getPageData();
    // _that.getPlatformListData().then(() => {
    //   _that.getPageData().then(() => {
    //   _that.getPublishPlatform({
    //     params: {
    //       corpIds: _that.pageAjax.data.publishCorpIds.join(",")
    //     }
    //   });
    // });
    // })
    _that.getPageData().then(() => {
      _that.getPlatformListData();
      if (
        !_that.$store.getters.hasChildrenCorporations ||
        !_that.pageAjax.data.publishCorpIds ||
        !_that.pageAjax.data.publishCorpIds.length
      ) {
        _that.pageAjax.data.publishCorpIds =
          _that.pageAjax.data.publishCorpIds || [];
        _that.pageAjax.data.publishCorpIds.push(
          _that.$store.state.userData.corporations[0].id
        );
      }
      _that.getPublishPlatform();
    });

    _that.uploadImgAjax.config.headers.Authorization =
      "bearer " + _that.$store.state.sid.access_token;
  },
  methods: {
    /* 上传图片 */
    rCloseImgPreviewCp() {
      this.imgPreviewCp.config.show = false;
    },
    rViewImg(index) {
      let _that = this;
      let arr = _that.pageAjax.data.pics;
      // arr.forEach((item) => {
      //   item =
      // });
      _that.imgPreviewCp.data = arr;
      _that.imgPreviewCp.index = index;
      _that.imgPreviewCp.config.show = true;
    },
    rUploadImgSuc(respData) {
      let _that = this;
      _that.uploadImgAjax.config.disabled = false;
      _that.uploadImgAjax.loading.close();
      _that.$refs.uploadImg.clearFiles();
      if (respData.code === _that.STATUS.success[0]) {
        _that.pageAjax.data.pics.push(respData.data.fileUrl);
        // _that.getPageData();
      } else {
        _that.$message.error({
          message: respData.msg || "上传失败",
          onClose() {}
        });
      }
    },
    rUploadImgFail() {
      let _that = this;
      _that.uploadImgAjax.loading.close();
      _that.uploadImgAjax.config.disabled = false;
      _that.$refs.uploadImg.clearFiles();
      _that.$message.error({
        message: "上传错误，请查看网络或联系管理员",
        onClose() {}
      });
    },
    rUploadImgProgress() {},
    rUploadImgBefore() {
      let _that = this;
      if (_that.pageAjax.data.pics.length >= 5) {
        _that.$message.error({
          message: "图片超过5张，请删除后再上传",
          onClose() {}
        });
        return false;
      }
      _that.uploadImgAjax.loading = this.$loading({
        text: "上传中。。。",
        lock: true
      });
    },
    rDeleteUploadImg(index) {
      let _that = this;
      this.$confirm("你确定要删除此数据?", "删除提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        _that.pageAjax.data.pics.splice(index, 1);
      });
    },
    /* 上传视频 */
    rCloseVideoPreviewCp() {
      this.videoPreviewCp.data.src = "";
      this.videoPreviewCp.config.show = false;
    },
    rViewVideo(src) {
      let _that = this;
      // arr.forEach((item) => {
      //   item =
      // });
      _that.videoPreviewCp.data.src = src;
      _that.videoPreviewCp.config.show = true;
    },
    rUploadVideoSuc(respData) {
      let _that = this;
      _that.uploadVideoAjax.config.disabled = false;
      _that.uploadVideoAjax.loading.close();
      _that.$refs.uploadVideo.clearFiles();
      if (respData.code === _that.STATUS.success[0]) {
        _that.pageAjax.data.videos.push(respData.data.fileUrl);
        // _that.getPageData();
      } else {
        _that.$message.error({
          message: respData.msg || "上传失败",
          onClose() {}
        });
      }
    },
    rUploadVideoFail() {
      let _that = this;
      _that.uploadVideoAjax.loading.close();
      _that.uploadVideoAjax.config.disabled = false;
      _that.$refs.uploadVideo.clearFiles();
      _that.$message.error({
        message: "上传错误，请查看网络或联系管理员",
        onClose() {}
      });
    },
    rUploadVideoProgress() {},
    rUploadVideoBefore() {
      let _that = this;
      if (_that.pageAjax.data.videos.length >= 3) {
        _that.$message.error({
          message: "视频超过3张，请删除后再上传",
          onClose() {}
        });
        return false;
      }
      _that.uploadVideoAjax.loading = this.$loading({
        text: "上传中。。。",
        lock: true
      });
    },
    rDeleteUploadVideo(index) {
      this.pageAjax.data.videos.splice(index, 1);
    },
    rAddVideoLink() {
      let _that = this;
      if (_that.pageAjax.data.videoLinks.length >= 3) {
        _that.$message.error("图片超过3张，请删除后再上传");
        return;
      }
      _that.pageAjax.data.videoLinks.push("");
    },
    rDeleteVideoLink(index) {
      let _that = this;
      _that.pageAjax.data.videoLinks.splice(index, 1);
    },
    rAddLiveExpEditVo() {
      let _that = this;
      let liveExpEditVoList = _that.pageAjax.data.liveExpEditVoList || [];
      liveExpEditVoList.push({});
      _that.pageAjax.data.liveExpEditVoList = liveExpEditVoList;
    },
    rDeleteLiveExpEditVo(index) {
      let _that = this;
      _that.pageAjax.data.liveExpEditVoList.splice(index, 1);
    },
    rSubmitForm() {
      let _that = this;
      let submitData = _.cloneDeep(_that.pageAjax.data);

      submitData.videoLinks = submitData.videoLinks || [];
      submitData.liveExpEditVoList = submitData.liveExpEditVoList || [];
      submitData.intentionPlatforms = submitData.intentionPlatforms || [];
      submitData.publishPlatformIds = submitData.publishPlatformIds || [];

      if (!submitData.nickName) {
        _that.$message.error("昵称不能为空");
        return;
      }

      for (var i = 0, lenI = submitData.videoLinks.length; i < lenI; i++) {
        if (!/^(http:\/\/)|(https:\/\/)/.test(submitData.videoLinks[i])) {
          _that.$message.error(
            "视频链接" + (i + 1) + "格式错误，必须以http或https开头"
          );
          return;
        }
      }
      if (!submitData.hasLiveExperience) {
        submitData.liveExpEditVoList.length = 0;
      }
      for (
        let i = 0, lenI = submitData.liveExpEditVoList.length;
        i < lenI;
        i++
      ) {
        if (!submitData.liveExpEditVoList[i].platfomId) {
          _that.$message.error("请输入直播经验" + (i + 1) + "的直播平台");
          return;
        }

        if (!submitData.liveExpEditVoList[i].liveId) {
          _that.$message.error("直播经验" + (i + 1) + "直播id不能为空");
          return;
        }
      }
      if (
        !submitData.pics.length &&
        !submitData.videos.length &&
        !submitData.videoLinks.length
      ) {
        _that.$message.error("图片、视频、视频链接不能都为空");
        return;
      }

      if (!submitData.intentionPlatforms.length) {
        _that.$message.error("意向平台不能为空");
        return;
      }
      if (!submitData.publishPlatformIds.length) {
        _that.$message.error("发布平台不能为空");
        return;
      }
      submitData.otherOpinion = _that.alone.pageAjax.data.otherOpinion;
      submitData.starLooks = _that.alone.pageAjax.data.starLooks;
      submitData.starSkills = _that.alone.pageAjax.data.starSkills;
      submitData.starEloquence = _that.alone.pageAjax.data.starEloquence;
      delete submitData.anchorRecruitAppraise;
      if (_that.pageAjax.loading) {
        return;
      }
      _that.pageAjax.loading = true;

      updateActor(submitData)
        .then(resp => {
          let respData = resp.data || {};

          if (respData.code === _that.STATUS.success[0]) {
            _that.$message.success({
              message: respData.msg || "添加失败",
              duration: 1200,
              onClose() {
                _that.goRefresh(-1);
              }
            });
          } else {
            _that.$message.error(respData.msg || "添加失败");
          }
        })
        .finally(() => {
          _that.pageAjax.loading = false;
        });
    },
    rChangePublishCorporations() {
      this.alone.platformList = this.pageAjax.data.publishPlatformIds = [];
      this.getPublishPlatform();
    },
    getPublishPlatform: _.debounce(function() {
      let _that = this;
      if (
        !_that.pageAjax.data.publishCorpIds ||
        !_that.pageAjax.data.publishCorpIds.length
      ) {
        return;
      }
      getAllCorporationsPlatformList({
        params: {
          corpIds: _that.pageAjax.data.publishCorpIds.join(","),
          mask: 2
        }
      })
        .then(resp => {
          let respData = resp.data || {};

          if (respData.code === _that.STATUS.success[0]) {
            // _that.alone.platformList = respData.data;

            let allPlatform = getOffspringnTree(respData.data, 0);
            // console.log("allPlatform", allPlatform);
            // _that.alone.platformList = allPlatform;
            let arrAll = {
              id: 0,
              name: "全部",
              parentId: -1
            };
            arrAll.children = allPlatform;
            _that.alone.platformList = [arrAll];
            // _that.alone.platformList = allPlatform;
          } else {
            _that.$message.error(respData.msg || "获取失败");
          }
        })
        .finally(() => {});
    }, 800),
    getPageData() {
      let _that = this;

      return getActorInfo({ params: { anchorId: _that.$route.query.anchorId } })
        .then(resp => {
          let respData = resp.data || {};

          if (respData.code === _that.STATUS.success[0]) {
            _that.pageAjax.data = respData.data;
            _that.pageAjax.data.talentSkills =
              _that.pageAjax.data.talentSkills || [];

            // let respResult = respData.data;
            // if (respResult.liveExpEditVoList && respResult.liveExpEditVoList.length) {
            //   respResult.liveExpEditVoList.map((item) => {
            //     item.platfomId = item.platfomId * 1;
            //     return item;
            //   });
            // }
          } else {
            _that.$message.error(respData.msg || "获取失败");
          }
        })
        .finally(() => {});
    },
    getPlatformListData() {
      let _that = this;
      let realTenantId = _that.pageAjax.data.tenantId; // 该主播真正属于的公司
      return getPlatformList(
        { params: { mask: 7, hierarchy: 1, tenantId: realTenantId } },
        { headers: { hasCorporationId: false } }
      )
        .then(resp => {
          let respData = resp.data;

          if (respData.code === _that.STATUS.success[0]) {
            let respResult = _.cloneDeep(respData.data);
            let topParentId = respResult[0].parentId;
            let respResultTile = tileNestingData(respResult);
            // console.log("respResultTile", respResultTile);
            // 直播经验id
            _that.platformListSupAjax.oldPlatfomList = _.cloneDeep(
              respData.data
            );

            // 意向平台
            let wantPlatformList = [];

            for (var i = 0, lenI = respResultTile.length; i < lenI; i++) {
              if (respResultTile[i].mask == 2) {
                wantPlatformList.push(respResultTile[i]);
              }
              // 所有平台和都是意向和发布
              if (respResultTile[i].mask == 7 || respResultTile[i].mask == 3) {
                // platformList.push(respResultTile[i]);
                wantPlatformList.push(respResultTile[i]);
              }
            }

            wantPlatformList.push({
              id: topParentId,
              name: "全部",
              parentId: -1
            });
            let wantPlatformListTree = getOffspringnTree(wantPlatformList, -1);
            _that.platformListSupAjax.wantPlatformList = wantPlatformListTree;
            // console.log(
            //   "_that.platformListSupAjax.wantPlatformList",
            //   wantPlatformListTree
            // );
            // 意向主播id
          }
        })
        .finally(() => {});

      // return _that.$store.dispatch("getPlatformList").then(() => {
      //   let arr =
      //     _.cloneDeep(
      //       _that.$store.getters.wantPlatformListOffspringnTreeData(1)
      //     ) || [];

      //   _that.platformListSupAjax.data = _.cloneDeep(arr);
      // });
    },
    back() {
      this.goRefresh(-1);
    }
    // getPlatformListData() {
    //   let _that = this;
    //   return _that.$store.dispatch("getPlatformList").then(() => {
    //     let arr =
    //       _.cloneDeep(
    //         _that.$store.getters.wantPlatformListOffspringnTreeData(1)
    //       ) || [];

    //     _that.platformListSupAjax.data = arr;
    //   });
    // }
  }
};
</script>
<style lang="scss" scoped>
.page {
  .block {
    display: block;
  }
  .inlineBlock {
    display: inline-block;
  }
  .mi-title {
    color: #999;
  }
  .s-search {
    border-bottom: 1px solid #eee;
  }
  .c-main {
    margin-top: 20px;
  }
  .c-pagination {
    margin-top: 20px;
    text-align: center;
  }
  .mi-upload {
    padding: 20px;
    .mi-title {
      margin-bottom: 20px;
    }
    .m-files {
    }
    .m-file {
      position: relative;
      float: left;
      width: 150px;
      height: 150px;
      margin-right: 10px;
      margin-bottom: 10px;
      border: 1px solid #ebeef5;
      box-sizing: border-box;
      img,
      video {
        display: block;
        width: 100%;
        height: 100%;
      }
      &:hover .m-operation {
        opacity: 1;
      }
    }
    .m-operation {
      opacity: 0;
      position: absolute;
      left: 0;
      top: 0;
      z-index: 10;
      width: 100%;
      height: 100%;
      background-color: rgba(0, 0, 0, 0.4);
      color: #fff;
      transition: opacity 0.4s;
      i {
        font-size: 20px;
        padding: 10px 20px;
      }
    }
    .m-addBtn {
      border: 1px dashed #c0ccda;
      border-radius: 10px;
      font-size: 28px;
      color: #ebeef5;
      &:hover {
        border-color: #409eff;
        color: #409eff;
      }
    }
  }
  .c-videoLink {
    .el-input {
      margin-right: 10px;
      width: 270px;
      vertical-align: top;
    }
  }
  .c-liveExpEditVoList {
    .c-liveExpEditVo {
      border-top: 1px solid #ebeef5;
      padding-top: 20px;
      .mi-title {
        padding-left: 20px;
      }
    }
  }
}
</style>
<style lang="scss">
.label-must .el-form-item__label:before {
  content: "*";
  color: #f56c6c;
  margin-right: 4px;
}
</style>
